from pages.base_page import BasePage
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select


class EditCluePage(BasePage):
    url = "/crm/index.php?m=leads&a=add"
    first_clue_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/form/table/tbody/tr[1]/td[12]/a[3]')
    saltname_locator = (By.ID,'saltname')
    edit_save_locator = (By.CSS_SELECTOR,'#form1 > table > tfoot > tr > td:nth-child(2) > input.btn.btn-primary')
    edit_save_success_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    mobile_phone_locator = (By.ID,'mobile')


    #点击第一个线索的编辑按钮
    def edit_first_clue(self):
        self.driver.find_element(*self.first_clue_locator).click()
    #点击编辑线索的尊称下拉框第一个
    def edit_first_saltname(self):
        select = Select(self.driver.find_element(*self.saltname_locator))
        select.select_by_index(1)
    #点击编辑线索的保存按钮
    def edit_save(self):
        self.driver.find_element(*self.edit_save_locator).click()
    #返回编辑线索的保存成功的提示信息
    def edit_save_success(self):
        return self.driver.find_element(*self.edit_save_success_locator).text
    #清空编辑线索的手机号
    def edit_mobile_phone_claer(self):
        self.driver.find_element(*self.mobile_phone_locator).clear()
    #输入编辑线索的手机号
    def edit_mobile_phone(self,phone_number):
        self.driver.find_element(*self.mobile_phone_locator).send_keys(phone_number)

